package day24;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;

public class Demo {
    public static void main(String[] args) throws IOException {
        //创建缓冲输入流  借助于字节输入流
        FileInputStream fis = new FileInputStream("D:\\aaa.txt");
        BufferedInputStream bis = new BufferedInputStream(fis);
        int c = bis.read();
        System.out.println("c："+c+"ok");
        c = bis.read();
        System.out.println(c);
        byte[] bs = new byte[10];
        bis.read(bs);
        System.out.println(Arrays.toString(bs));
        //缓冲输出流
        FileOutputStream fos = new FileOutputStream("D:\\a\\text.txt");
        BufferedOutputStream bos = new BufferedOutputStream(fos);
        //由于缓冲流在缓冲区保存的 如果没有清空缓存  数据不会到本地磁盘
        bos.write(97);
        bos.write(65);
        bos.write("你好".getBytes());
        bos.flush();//清空缓存
        bos.close();//再关闭
    }
}
